//
//  LoginPresenter.swift
//  MVP框架设计_Swift
//
//  Created by globalives2 on 2017/2/27.
//  Copyright © 2017年 globalives2. All rights reserved.
//

import UIKit

class LoginPresenter: NSObject {
    
    // p层用于关联V层和m层
    private var view:LoginView?
    private var model:LoginModel?
    
    override init() {
        super.init()
        self.model = LoginModel()
    }
    func attachView(view:LoginView) {
        self.view = view
    }
    
    func detachView(){
        self.view = nil
    }
    
    // 提供业务方法
    func login(name:String,password:String) {
        self.model?.login(name: name, password: password, callback: { (result) in
            
            if (self.view != nil) {
                self.view?.onLoginResult(result: result)
            }
            
        })
    }
}
